package cc.comac.mom.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.EquipInventorySpareRelationService;
import cc.comac.mom.bean.EquipInventorySpareRelation;
import cc.comac.mom.bean.ResultDev;
import cc.comac.mom.entity.EquipInventorySpareRelationEntity;
import cc.comac.mom.util.ResultBean;

@RestController
@RequestMapping("/EquipInventorySpareRelation")
public class EquipInventorySpareRelationController {
	@Autowired
	private EquipInventorySpareRelationService equipInventorySpareRelationService;

	// 查询备件数据通过盘点id
	@RequestMapping(value = "/selectSpareDataByInventotyId",method = RequestMethod.POST)
	public ResultBean selectSpareDataBynventotyId(
			@RequestBody EquipInventorySpareRelation equipInventorySpareRelation) {
		ResultBean resultBean = new ResultBean(true);
		try {
			ResultDev selectSpareDataBynventotyId = equipInventorySpareRelationService
					.selectSpareDataBynventotyId(equipInventorySpareRelation);
			resultBean.setObject(selectSpareDataBynventotyId);
		} catch (RuntimeException e) {
			resultBean.setErrorMessge(e.getMessage());
			return resultBean;
		}
		return resultBean;
	}

	// 批量逻辑删除
	@RequestMapping(value = "/batchDelete",method = RequestMethod.POST)
	public ResultBean batchDelete (@RequestBody List<EquipInventorySpareRelationEntity> list) {
			ResultBean resultBean = equipInventorySpareRelationService.batchDelete(list);
		
		return resultBean;
	}
}
